package com.example.demo.mapper;

import com.example.demo.entity.Colleges;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CollegesMapper {

    @Select("<script>select * from colleges where 1=1 " +
            "<if test = 'college != null'>and college like concat('%',#{college},'%')</if></script>")
    List<Colleges> selectByCollege(@Param("college") String college);

    @Select("select * from colleges")
    List<Colleges> selectAllVersion();

    @Select("select * from colleges where college=#{college} and version=#{version}")
    Colleges selectByCollegeAndVersion(@Param("college") String college, @Param("version") String version);

    @Insert("<script>insert into colleges(college,graduationGredit,englishTestFour,computerLevel,totalCredit,version)" +
            "<foreach collection = 'colleges' item='record' separator=',' >" +
            " values(#{record.college},#{record.graduationGredit},#{record.englishTestFour},#{record.computerLevel},#{record.totalCredit},#{record.version})" +
            "</foreach></script>")
    int add(@Param("colleges") List<Colleges> colleges);
}
